<%@ page import="util.DBUtil" %>
<%@ page import="java.sql.ResultSet" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023/12/15
  Time: 10:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>我的订单列表</title>
</head>
<body>
<h3>我的订单</h3>
<table>
    <tr>
        <td>订单编号</td>
        <td>金额</td>
        <td>下单日期</td>
        <td>状态</td>
        <td>操作</td>
    </tr>
    <%
        //取所有订单
        DBUtil dbUtil =new DBUtil();
        String sql="select * from tb_order order by id desc";
        ResultSet rs=dbUtil.query(sql);
        while (rs.next()){
            out.print("<tr>");
            out.print("<td>"+rs.getString("order_no")+"</td>");
            out.print("<td>"+rs.getString("total_money")+"</td>");
            out.print("<td>"+rs.getString("order_date")+"</td>");
            String statusName="";
            switch (rs.getInt("status")){
                case 0: statusName="待支付";break;
                case 1: statusName="已支付，待发货";break;
                case 2: statusName="已发货";break;
            }
            out.print("<td>"+statusName+"</td>");
            //根据订单状态的不同，显示不同的操作按钮
            out.print("<td>");
            if(rs.getInt("status")==0) {
                out.print("<a href=\"cancel.jsp?id="+rs.getInt("id")+"\">撤单</a>");
                out.print("<a href=\"buy.jsp?id="+rs.getInt("id")+"\">付款</a>");
            }
            if (rs.getInt("status")==1)
                out.print("<a href=\"\">退款</a>");

            if (rs.getInt("status")==2)
                out.print("<a href=\"\">退货</a>");
            out.print("<a href=\"\">签收</a>");
            out.print("<a href=\"\">评价</a>");
            out.print("</td>");
        }
    %>
</table>
</body>
</html>
